<!--
 * @Description: el-tree基础封装
 * @Author: zhanyinjia
 * @Date: 2022-05-20 16:21:14
 * @LastEditors: zhanyinjia
 * @LastEditTime: 2022-11-30 14:25:27
-->
<template>
  <div class="tree">
    <cus-tree
      :tree-data.sync="list"
      :file-drop="fileDrop"
      :director-drop="directorDrop"
      :delete="deleteFn"
      :rename="renameFn"
    ></cus-tree>
  </div>
</template>

<script>
import { list } from '@/data/treeJson'
export default {
  name: 'Tree',
  data() {
    return {
      fileDrop: [
        {
          action: 'delete',
          label: '删除'
        }
      ],
      directorDrop: [
        {
          action: 'update',
          label: '重命名'
        },
        {
          action: 'delete',
          label: '删除'
        }
      ],
      list
    }
  },
  methods: {
    renameFn() {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve({ err: 0, message: '修改成功' })
        }, 1000)
      })
    },
    deleteFn() {
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve({ err: 0, message: '删除成功' })
        }, 1000)
      })
    }
  }
}
</script>
<style lang="less" scope>
.tree {
  width: 300px;
}
</style>
